using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using DAL;
using BUS;
using Utility;

public partial class Admin_KhachHangUpdate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }
    private void LoadData()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbKhachHang  kh = tbKhachHangBUS .GetByID(id);
            if (kh != null)
            {
                txt_makh.Text = kh.IDKhachHang.ToString();
                txt_tenkh.Text = kh.TenKH ;
                txt_dc.Text = kh.DiaChi;
                txt_dt.Text = kh.DienThoai;
                txt_email.Text = kh.Email;
                txt_tk.Text = kh.TaiKhoan;
                txt_mk.Text = kh.MatKhau;
            }
        }
        catch
        {
            Response.Redirect("~/Admin/KhachHangList.aspx");
        }

    }
    protected void btkh_update_Click(object sender, EventArgs e)
    {
        tbKhachHang kh = new tbKhachHang();
        kh.IDKhachHang = int.Parse(txt_makh.Text);
        kh.TenKH = txt_tenkh.Text;
        kh.DiaChi = txt_dc.Text;
        kh.DienThoai = txt_dt.Text;
        kh.Email = txt_email.Text;
        kh.TaiKhoan = txt_tk.Text;
        kh.MatKhau = txt_mk.Text;
        tbKhachHangBUS.Update(kh);
        Response.Redirect("~/Admin/KhachHangList.aspx");
    }
}
